
import { Controller, Get, Post, Body, Req, SetMetadata, UsePipes, ValidationPipe } from '@nestjs/common';
import { UserDto } from './user.dto';
import { AuthService } from './auth.service'
@SetMetadata('isLogger', true)
@Controller()
export class AuthController {

    constructor(private readonly authService: AuthService) { }

    @UsePipes(new ValidationPipe())
    @SetMetadata('isNoAuth', true)
    @Post('/register')
    async register(@Body() userDto: UserDto) {
        return this.authService.register(userDto);
    }

    // @UsePipes(new ValidationPipe())
    @SetMetadata('isNoAuth', true)
    @Post('/login')
    login(@Body() userDto: UserDto,@Req() request: Request) {
        return this.authService.login(userDto);
    }

    @Get('/getUserInfo')
    getUserInfo(@Req() req) {
        const { userInfo } = req;
        return userInfo
    }

    @SetMetadata('isNoAuth', true)
    @Get('/selects')
    async selects() {
        return this.authService.selects()
    }

    @Get('/getMenu')
    async getMenu(@Req() req) {
        return this.authService.getMenu(req)
    }


}